﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.IO;

namespace AnaGiftedProject
{
    public partial class WebForm8 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            using (DatabaseGiftedEntities ctx=new DatabaseGiftedEntities())
            {
                string imagefolder = "storeimg";
                string savepath;
                string savefile;
                StoreImg storimg = new StoreImg();
                if (FileUpload1.PostedFile != null)
                {
                    savepath = Path.Combine(Request.PhysicalApplicationPath, imagefolder);
                    savefile = Path.Combine(savepath, FileUpload1.FileName);
                    FileUpload1.SaveAs(savefile);
                    storimg.StoreImgName = txtName.Text;
                    storimg.Price = txtPrice.Text;
                    storimg.ImgInfo = txtInfo.Text;
                    storimg.StoreImgTrack = savepath;
                }
                ctx.AddToStoreImgs(storimg);
                ctx.SaveChanges();
                DataList1.DataBind();
            }
        }
    }
}